package org.gruposp2p.proyectokarma.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.GeneratedValue;

import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.Resolution;

@Entity
@Table(name="Tag")
public class Tag  implements java.io.Serializable {

	 private static final long serialVersionUID = 1L;
	 
	 @Id @GeneratedValue(strategy=IDENTITY)
     @Column(name="id", unique=true, nullable=false)
     private Long id;
     @Column(name="name", nullable=false, length=50)
     private String name;
     @Column(name="frequency")
     private Long frequency;
     @DateBridge( resolution = Resolution.DAY )
     @Temporal(TemporalType.TIMESTAMP)
     @Column(name="dateCreated", length=23)
     private Date dateCreated;
     @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="tag")
     private Set<DocumentTag> documentTags = new HashSet<DocumentTag>(0);

    public Tag() { }
	
    public Tag(Long id, String name) {
        this.id = id;
        this.name = name;
    }
    
    public Tag(Long id, String name, Set<DocumentTag> documentTags) {
       this.id = id;
       this.name = name;
       this.documentTags = documentTags;
    }
   
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }

    public Set<DocumentTag> getDocumentTags() {
        return this.documentTags;
    }
    
    public void setDocumentTags(Set<DocumentTag> documentTags) {
        this.documentTags = documentTags;
    }

	public void setFrequency(Long frequency) {
		this.frequency = frequency;
	}

	public Long getFrequency() {
		return frequency;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

}


